package com.lyn.pluginbazaar.config;

import com.lyn.pluginbazaar.utils.FileUtil;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.ShallowEtagHeaderFilter;

import java.util.Arrays;

@Configuration
public class FileConfig {

    @Bean
    public void initFile() {
        FileUtil.createFolder(FileUtil.PLUGIN_PATH);
        FileUtil.createFolder(FileUtil.PLUGIN_FILE_PATH);
    }

    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        FilterRegistrationBean filterBean = new FilterRegistrationBean();
        filterBean.setFilter(new ShallowEtagHeaderFilter());
        filterBean.setUrlPatterns(Arrays.asList("*"));
        return filterBean;
    }

}
